<!-- 
    @author Wójcik Karol <wojcikk@student.agh.edu.pl>
    @licence http://www.gnu.org/copyleft/gpl.html GNU/GPL
-->

<div id="colOne">
    <%= render :partial => "menu" %>
</div>
<div id="colTwo">

<% if @subjects.blank? %>
    <h1>Aktualnie nie ma dost&#281;pnych przedmiot&#243;w</h1>
<% else %>

<h1>Przedmioty</h1>

<table>
  <tr>
    <th><a href="/subjects/?sortby=name">Nazwa</a></th>
    <th><a href="/subjects/?sortby=year">Rok</a></th>
    <th><a href="/subjects/?sortby=major">Kierunek</a></th>
    <th><a href="/subjects/?sortby=notes">Notatki</a></th>
  </tr>
  
<% for subject in @subjects %>
  <tr>
    <td><%= link_to "#{subject.name}", :controller => "lessons", :action => "list_for_subject", :id => subject.id %></td>
    <td><%=h subject.year %></td>
    <td><%=h subject.major.name %></td>
    <td><%=h subject.notes %></td>
    
    <td><%= link_to 'Poka&#380;', :action => 'show', :id => subject %></td>
    <td><%= link_to 'Zmie&#324;', :action => 'edit', :id => subject %></td>
    <td><%= link_to 'Usu&#324;', { :action => 'destroy', :id => subject }, :confirm => 'Are you sure?', :post => true %></td>
  </tr>
<% end %>
</table>

<%= link_to 'Previous page', { :page => @subject_pages.current.previous } if @subject_pages.current.previous %>
<%= link_to 'Next page', { :page => @subject_pages.current.next } if @subject_pages.current.next %> 

<br />
<% end %>

<%= link_to 'Utw&#243;rz nowy', :action => 'new' %>

</div>